package com.vegetable.modules.mapper.finance;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vegetable.modules.entity.finance.PaymentPurchase;
import com.vegetable.modules.entity.finance.po.AgentDeliveryStatisticsPO;
import com.vegetable.modules.entity.finance.po.PurchaseDeliveryStatisticsPO;
import com.vegetable.modules.entity.finance.vo.PaymentAgentStatisticsVO;
import com.vegetable.modules.entity.finance.vo.PaymentPurchaseStatisticsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 采购/代办付款 Mapper 接口
 * </p>
 *
 * @author wangruijie
 * @since 2024-04-15
 */
@Mapper
public interface PaymentPurchaseMapper extends BaseMapper<PaymentPurchase> {

    /**
     * 生成流水单号
     * @return
     */
    String getNextCode();

    IPage<PaymentAgentStatisticsVO> agentDeliveryStatistics(IPage page, AgentDeliveryStatisticsPO po);

    PaymentAgentStatisticsVO agentDeliveryStatistics2(AgentDeliveryStatisticsPO po);

    IPage<PaymentPurchaseStatisticsVO> purchaseDeliveryStatistics(IPage page, PurchaseDeliveryStatisticsPO po);

    PaymentPurchaseStatisticsVO purchaseDeliveryStatistics2(PurchaseDeliveryStatisticsPO po);

    /**
     * 查询未完全匹配的付款记录
     * @return 付款记录列表
     */
    @Select("SELECT * FROM payment_purchase WHERE state = 0 ORDER BY create_time ASC")
    List<PaymentPurchase> selectUnmatchedPayments();
}